<?php
class mlocationpicture extends CI_Model{
	var $locationpic = "location_picture";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_locationpic,$id_location,$file_locationpic,$description_locationpic)
	{
		$this->id_locationpic = $id_locationpic;
		$this->id_location = $id_location;
		$this->file_locationpic = $file_locationpic;
		$this->description_locationpic = $description_locationpic;
	}
	
	function getList($id_location,$page,$uri_segment){
		$this->db->where('id_location', $id_location);
		$query = $this->db->get($this->locationpic, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->locationpic);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_locationpic'=>$this->id_locationpic,
			'id_location'=>$this->id_location,
			'file_locationpic'=>$this->file_locationpic,
			'description_locationpic'=>$this->description_locationpic
		);
		return $this->db->insert($this->locationpic, $arrayData);
	}
	
	function update($id_locationpic)
	{
		$arrayData = array(
			'id_location'=>$this->id_location,
			'file_locationpic'=>$this->file_locationpic,
			'description_locationpic'=>$this->description_locationpic
		);
		$this->db->where('id_locationpic', $id_locationpic);
		return $this->db->update($this->locationpic, $arrayData);
	}
        
	function remove($id_locationpic)
	{
		$this->db->where('id_locationpic', $id_locationpic);
		return $this->db->delete($this->locationpic);
	}	
	
	function detail($id_locationpic)
	{
		$this->db->where('id_locationpic', $id_locationpic);
		$query = $this->db->get($this->locationpic);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('file_locationpic',$name);
		$query = $this->db->get($this->locationpic);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($id_location){
		$this->db->where('id_location', $id_location);
		$query = $this->db->get($this->locationpic);
		return $query->result_array();
	}
}
?>